package com.oa.tools.controller;

import java.util.HashMap;
import java.util.Map;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity;
//import org.springframework.security.core.token.TokenService;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
@RequestMapping("/token")
public class TokenController {
	
//	@Autowired
//	TokenService tokenService;
	
	@PostMapping
	public ResponseEntity<Map<String,Object>> login(@RequestBody Map<String,String> userInfo){
		String uername = userInfo.get("username");
		String password = userInfo.get("password");
		
		
		HashMap<String,Object> result = new HashMap<String,Object>();
		
		String token = null;//tokenService.login(uername,password);
		
		if(token==null) {
			result.put("message", "invalid username or password");
			return ResponseEntity.status(HttpStatus.BAD_REQUEST).body(result);
		}
		
		result.put("token", token);
		return ResponseEntity.status(HttpStatus.OK).body(result);
	}
}
